﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BSCMFF.Core.BusinessLayer;
using BSCMFF.Core;

namespace BSCMFF.Web.Pages.Administration
{
    public partial class CompanyInfo : MultiLanguagePage
    {
        public BSCMFF.Core.DataAccessLayer.DataObjects.CompanyInfo ci;

        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                CompanyInfoManager cim = new CompanyInfoManager();

                ci = cim.GetCompanyInfo();
                this.DataBind();
            }
        }

        protected void RadButtonUploadLogo_Click(object sender, EventArgs e)
        {
            ci = new Core.DataAccessLayer.DataObjects.CompanyInfo();

            ci.CompanyName = RadTextBoxCompanyName.Text;
            ci.CompanyAddress1 = RadTextBox1.Text;
            //ci.CompanyAddress2 = RadTextBox2.Text;
            ci.CompanyCity = RadTextBox3.Text;
            ci.CompanyZip = RadTextBox5.Text;
            ci.CompanyCountry = RadTextBox6.Text;
            ci.CompanyPhone = RadTextBox7.Text;
            ci.CompanyURL = RadTextBox8.Text;
            ci.CompanyEmail = RadTextBox9.Text;

            long length = RadUploadLogo.UploadedFiles[0].InputStream.Length;
            //u.Photo = new byte[length];
            byte[] buff = new byte[length];
            RadUploadLogo.UploadedFiles[0].InputStream.Read(buff, 0, (int)length);

            ci.CompanyLogo = buff; // RadBinaryImageLogo.DataValue;

            

            CompanyInfoManager cim = new CompanyInfoManager();
            cim.UpdateCompanyInfo(ci);

            //RadBinaryImageLogo.DataBind();
        }
    }
}